import { defineStore } from "pinia";
import { ref } from "vue";
// 定义 Store
export const InfoStore = defineStore(
  "Info",
  () => {
    const LoginInfo = ref();
    const clearProfile = () => {
      LoginInfo.value = undefined;
    };
    const setProfile = (data) => {
      LoginInfo.value = data;
    };

    // 记得 return
    return {
      LoginInfo,
      setProfile,
      clearProfile,
    };
  },
  // TODO: 持久化
  {
    //网页端配置
    //persist: true,
    //小程序端配置
    persist: {
      storage: {
        getItem(key) {
          return uni.getStorageSync(key);
        },
        setItem(key, value) {
          return uni.setStorageSync(key, value);
        },
      },
    },
  }
);
